<!--
  @author yangjiangming
  @date 2018-12-10 20:40:28
-->
<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-4.dtd">
<html th:replace="~{work/modify/common/layout :: layout('退款', ~{::title}, ~{::content}, ~{::script})}">
<head>
    <title>工单管理-退款单</title>
</head>
<body>
<div th:fragment="content">
    <style>
        span {
            line-height: 34px;
        }
        label.refund_account:before {
            content: '* ';
            color: #ff0000;
        }
    </style>
    <form class="layui-form">
        <input type="text" name="workId" th:value="${workId}" hidden>
        <input type="text" name="orderId" th:value="${orderId}" hidden>
        <input type="text" name="opType" th:value="${opType}" hidden>
        <!-- 工单状态 -->
        <input type="text" name="status" th:value="${refundVO.status}" hidden>
        <!-- 工单结果  -->
        <input type="text" name="resultStatus" th:value="${refundVO.resultStatus}" hidden>


        <div class="layui-form-item">
            <label class="layui-form-label">金额信息</label>
            <div class="layui-inline" style="padding: 6px 15px 0px 0px;" th:text="${'原单收入：' + #moneyUtil.parseToYuanStartWithUnit(refundVO.originalAmount)}">
            </div>
            <div class="layui-inline" style="padding: 6px 15px 0px 0px;" th:text="${'已退金额：' + #moneyUtil.parseToYuanStartWithUnit(refundVO.haveRefundAmount)}">
            </div>
        </div>

        <div class="layui-form-item" th:if="${not #lists.isEmpty(refundVO.companyList)}">
            <label class="layui-form-label">退款服务商</label>
            <div class="layui-inline" style="width: 320px">
                <select id="companyId" name="companyId" lay-verify="required" lay-search="" lay-filter="companyId" disabled>
                    <option value="">请选择</option>
                    <option th:each="item : ${refundVO.companyList}"
                            th:text="${item.text}"
                            th:value="${item.value}"
                            th:selected="${item.selected}">
                    </option>
                </select>
            </div>
        </div>

        <div class="layui-form-item" >
            <label class="layui-form-label">退款工程师</label>
            <div class="layui-input-block reworkReward">
                <table class="layui-table" id="masters" lay-filter="masters"></table>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">退款方式：</label>
            <div class="layui-input-block">
                <block th:if="${refundVO.supportBacktracking}">
                    <input type="radio" name="refundType" value="1" title="原路退款" lay-filter="refundType"
                           th:checked="${refundVO.supportBacktracking}">
                </block>
                <block th:if="${refundVO.supportManualRefund && #orderAuthPermit.checkPermit(moduleId, #orderPremissionConsts.ODP_MANUAL_REFUND)}">
                    <input type="radio" name="refundType" value="2" title="人工退款" lay-filter="refundType"
                           th:checked="${!refundVO.supportBacktracking && refundVO.supportManualRefund }">
                </block>
            </div>
        </div>

        <div class="layui-form-item" id="offline_refund_path" style="display: none">
            <label class="layui-form-label">退款路径：</label>
            <div class="layui-input-block">
                <block >
                    <input type="radio" name="payTargetChannelId" value="1" title="支付宝" lay-filter="payTargetChannelId" th:checked="${refundVO.payTargetChannelId == 1 ? true :false}">
                    <input type="radio" name="payTargetChannelId" value="2" title="微信" lay-filter="payTargetChannelId" th:checked="${refundVO.payTargetChannelId == 2 ? true :false}">
                    <input type="radio" name="payTargetChannelId" value="5" title="银行卡" lay-filter="payTargetChannelId" th:checked="${refundVO.payTargetChannelId == 5 ? true :false}">
                </block>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">退款信息：</label>
                <block th:if="${refundVO.supportBacktracking}" id="online_refund_amount" style="display: none">
                    <input class="layui-input"
                           id="online_amount"
                           type="number"
                           autocomplete="off"
                           th:placeholder="${'有' + #moneyUtil.parseToYuanEndWithUnit(maxBacktrackingAmount)}+'可原路退款'"
                           lay-verify="online_amount"
                           th:value="${refundVO.refundType != null && refundVO.refundType == 1 ? #moneyUtil.parseToYuan(refundVO.refundAmount) : ''}"
                           th:disabled="${refundVO.updateRefundAmount == yesOrNo.no }"
                           style="width: 250px;"/>

                    <block th:if="${refundVO.noBacktrackingAmountVO.engineerPayAmount}">
                        <div style="margin-left: 110px"
                              th:text="${'有' + #moneyUtil.parseToYuanEndWithUnit(refundVO.noBacktrackingAmountVO.engineerPayAmount)}+'为工程师代用户支付，不可原路退款'"></div>
                    </block>

                    <block th:if="${refundVO.noBacktrackingAmountVO.channelPrepayAmount}">
                            <div style="margin-left: 110px"
                                  th:text="${'有' + #moneyUtil.parseToYuanEndWithUnit(refundVO.noBacktrackingAmountVO.channelPrepayAmount)}+'支付给渠道，不可原路退款'"></div>
                    </block>

                    <block th:if="${refundVO.noBacktrackingAmountVO.bankPayAmount}">
                        <div style="margin-left: 110px"
                             th:text="${'有' + #moneyUtil.parseToYuanEndWithUnit(refundVO.noBacktrackingAmountVO.bankPayAmount)}+'为对公转账，不可原路退款'"></div>
                    </block>
                </block>

                <block th:if="${refundVO.supportManualRefund}" id="offline_refund_amount" style="display: none">
                    <input class="layui-input"
                           id="offline_amount"
                           type="number"
                           autocomplete="off"
                           th:placeholder="${'本次最多可退款' + #moneyUtil.parseToYuanEndWithUnit(maxRefundAmount)}"
                           lay-verify="offline_amount"
                           th:value="${refundVO.refundType != null && refundVO.refundType == 2 ? #moneyUtil.parseToYuan(refundVO.refundAmount) : ''}"
                           th:disabled="${refundVO.updateRefundAmount == yesOrNo.no }"
                           style="margin-left: 110px;width: 250px;"/>
                </block>
            </div>

        <div class="layui-form-item" id="offline_refund_account">
            <label class="layui-form-label refund_account">账户：</label>
            <block id="alipayInfo" style="display: none">
                <div class="layui-input-block">
                    <input th:value="${refundVO.payTargetChannelId == 1 ? refundVO.payeeThirdAccountName : ''}" type="text" name="payeeThirdAccountName" placeholder="请填写支付宝真实姓名" autocomplete="off" class="layui-input" style="width: auto">
                </div>
                <div class="layui-input-block">
                    <input th:value="${refundVO.payTargetChannelId == 1 ? refundVO.payeeThirdAccount :''}" type="text" name="payeeThirdAccount" placeholder="请填写支付宝账号" autocomplete="off" class="layui-input" style="width: auto">
                </div>
            </block>
            <block id="weixinInfo" style="display: none">
                <div class="layui-input-block">
                    <input th:value="${refundVO.payTargetChannelId == 2 ? refundVO.payeeThirdAccountName : ''}" type="text" name="payeeThirdAccountName" placeholder="请填写微信绑定手机号" autocomplete="off" class="layui-input" style="width: auto">
                </div>
                <div class="layui-input-block">
                    <input th:value="${refundVO.payTargetChannelId == 2 ? refundVO.payeeThirdAccount : ''}" type="text" name="payeeThirdAccount" placeholder="请填写微信ID" autocomplete="off" class="layui-input" style="width: auto">
                </div>
            </block>
            <block id="bankInfo" style="display: none">
                <div class="layui-input-block">
                    <input th:value="${refundVO.payTargetChannelId == 5 ? refundVO.payeeThirdAccountBank : ''}" type="text" name="payeeThirdAccountBank" placeholder="开户行" autocomplete="off" class="layui-input" style="width: auto">
                </div>
                <div class="layui-input-block">
                    <input th:value="${refundVO.payTargetChannelId == 5 ? refundVO.payeeThirdAccount : ''}" type="text" name="payeeThirdAccount" placeholder="银行卡号" autocomplete="off" class="layui-input" style="width: auto">
                </div>
                <div class="layui-input-block">
                    <input th:value="${refundVO.payTargetChannelId == 5 ? refundVO.payeeThirdAccountName : ''}" type="text" name="payeeThirdAccountName" placeholder="户名" autocomplete="off" class="layui-input" style="width: auto">
                </div>
            </block>
            <block id="cashInfo" style="display: none">
                <div class="layui-input-block">
                    <label class="layui-form-label" style="width: auto">请线下退：现金</label>
                </div>
            </block>
        </div>

        <div class="layui-row">
            <div class="layui-col-md12">
                <div class="layui-form-item" id="reason">
                    <label class="layui-form-label">退款缘由：</label>
                    <div class="layui-input-block layui-col-space10">
                        <div class="layui-col-md4" th:each="reason:${refundVO.refundReason}">
                            <input th:title="${reason.text}" name="reason" th:value="${reason.value}"
                                   type="radio"
                                   lay-skin="primary"
                                   th:checked="${reason.selected}"
                                   title="退款缘由">
                        </div>
                    </div>
                </div>
                <div class="layui-form-item" id="originalCode-wrapper" style="display: none;"></div>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"></label>
            <div class="layui-inline" style="width: 800px">
                <textarea class="layui-textarea"
                          name="content"
                          placeholder="请输入其他缘由,小于200字"
                          maxlength="200"
                          lay-verify="content"
                          th:text="${refundVO.content}">
                </textarea>
            </div>
        </div>

        <div class="layui-form-item" style="text-align: center;">
            <button class="layui-btn " lay-submit>保存</button>
        </div>
    </form>
</div>

<script th:inline="javascript">
     var plat = [[${refundVO.platWork}]];
     var refundVO = [[${refundVO}]];
     var maxRefundAmount = [[${maxRefundAmount}]];
     var maxBacktrackingAmount = [[${maxBacktrackingAmount}]];
     var supportBacktracking = [[${refundVO.supportBacktracking}]];
     var refundReasonList = [[${refundVO.refundReason}]] || [];
     var isUpdate = [[${isUpdate}]];
     // 原路退收款账户
     var payerThirdAccount = [[${refundVO.payerThirdAccount}]];
     var layuiModel = {
         oms_work_modify_refund: "work/modify/zmn.oms.work.modify.refund"
     };
</script>
</body>
</html>